\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mana-book}[ Language report class]

\LoadClass[]{memoir}
\usepackage[top=2cm, bottom=2cm, right=2cm]{geometry}

\RequirePackage{xltxtra}
\RequirePackage{etoolbox}

\RequirePackage{polyglossia}
\setmainlanguage{russian}
\setotherlanguage{english}
\setkeys{russian}{babelshorthands=true, indentfirst=false}

\usepackage{paratype}
\usepackage[T1]{fontenc}

\setmainfont{PT Serif}
\setromanfont{PT Serif}
\setsansfont{PT Sans}
\setmonofont{PT Mono}

\newfontfamily{\cyrillicfont}{PT Serif}
\newfontfamily{\cyrillicfontrm}{PT Serif}
\newfontfamily{\cyrillicfonttt}{PT Mono}
\newfontfamily{\cyrillicfontsf}{PT Sans}

\addto\captionsrussian{%
  \renewcommand{\figurename}{Рис.}%
  \renewcommand{\tablename}{Табл.}%
}

%
% Commands for language name and company name
%
\newcommand{\arslang}{Арc}
\newcommand{\arvlang}{Арвиль}
\newcommand{\trilang}{Тривиль}

\newcommand{\theauthor}{Алексей Недоря}

%=============

%\RequirePackage{iftex}

%\RequirePackage{unicode-math}
%\defaultfontfeatures{Scale=MatchLowercase}
%\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}

\RequirePackage{multirow}
\RequirePackage[section]{minted}
\RequirePackage{xcolor}
\definecolor{darkblue}{rgb}{0.0, 0.0, 0.45}
\definecolor{LightGray}{gray}{0.95}
\definecolor{KeywordColor}{rgb}{0.20, 0.20, 0.5}

% Index commands
\RequirePackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, intoc]

%\RequirePackage{authblk}

\RequirePackage{fancyvrb}
\renewcommand{\theFancyVerbLine}{%
{\footnotesize\arabic{FancyVerbLine}}}

\newcommand{\keyword}[1]{\textbf{\textcolor{KeywordColor}{#1}}}
\newcommand{\cautiously}[1]{\textcolor{red}{#1}}

\DefineVerbatimEnvironment%
{Grammar}{Verbatim}
{frame=lines,formatcom=\color{blue},rulecolor=\color{black},fontsize=\small,vspace=2pt}

\newenvironment{Trivil}%
{%
  \VerbatimEnvironment
  \begin{listing}[H]
  \begin{minted}[
frame=lines,
framesep=1mm,
%baselinestretch=1.2,
bgcolor=LightGray,
fontsize=\small,
linenos
]{trivil}%
}%
{%
  \end{minted}%
  \end{listing}%
}%
\usemintedstyle[trivil]{sas}

%\DefineVerbatimEnvironment%
%{SampleErr}{Verbatim}
%{frame=single,numbers=left, rulecolor=\color{red}}

\newenvironment{SampleErr}%
{%
  \VerbatimEnvironment
  \begin{listing}[H]
  \begin{minted}[
frame=single,
rulecolor=\color{red},
framesep=1mm,
%baselinestretch=1.2,
bgcolor=LightGray,
fontsize=\small,
linenos
]{trivil}%
}%
{%
  \end{minted}%
  \end{listing}%
}%

\newenvironment{Ars}%
{%
  \VerbatimEnvironment
  \begin{listing}[H]
  \begin{minted}[
frame=lines,
framesep=1mm,
%baselinestretch=1.2,
%bgcolor=DarkGray,
bgcolor=LightGray,
fontsize=\small,
linenos
]{ars}%
}%
{%
  \end{minted}%
  \end{listing}%
}%
\usemintedstyle[ars]{xcode} %xcode - светлый, monokai - темный

\BeforeBeginEnvironment{minted}{\vspace{-0.4cm}}
\AfterEndEnvironment{minted}{\vspace{-1.2cm}}

% Highlights
\RequirePackage{soul}
\newcommand{\needlink}{\sethlcolor{yellow}\hl{link}}
\newcommand{\TBD}{\sethlcolor{orange}\hl{TBD}}

\RequirePackage[numbered]{bookmark}

\makeatletter

% hyperref should be last import
\RequirePackage{hyperref}
\hypersetup{unicode=true, bookmarks=true}

% Internal refs
\newcommand{\See}[1]{\S\ref{#1}\seechecknextarg}
\newcommand{\seechecknextarg}{\@ifnextchar\bgroup{\seegobblenextarg}{}}
\newcommand{\seegobblenextarg}[1]{\@ifnextchar\bgroup{, \S\ref{#1}\seegobblenextarg}{ \textit{and} \S\ref{#1}}}

%External refs
\newcommand{\myref}[1]{\textcolor{blue}{#1}}

\makeatother

%dense itemize
\newenvironment{d_itemize}{
\begin{itemize}
  \setlength{\itemsep}{2pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
}{\end{itemize}}

%==================


